package client;

import beans.User;
import model.UserLoginInfoModel;
import swing.FrameManager;

/**
 * 用户登录会话信息
 */
public class UserSession {

    public static User user = new User();
    private static String user_login_token = "";

    public static void initLoginSession(UserLoginInfoModel userLoginInfoModel) {
        user = userLoginInfoModel.getUser();
        user_login_token = userLoginInfoModel.getToken();
    }

    public static void clearLoginSession() {
        user = new User();
        user_login_token = "";
    }

    public static long LoginUser() {
        return user.getId();
    }

    public static String UserAccount() {
        return user.getAccount();
    }

    public static String Token() {
        return user_login_token;
    }

    public static void addAchievement(int word_add, int meaning_add, int meaning_update) {
        user.setWord_count(user.getWord_count() + word_add);
        user.setMeaning_count(user.getMeaning_count() + meaning_add);
        user.setUpdate_meaning_count(user.getUpdate_meaning_count() + meaning_update);
        FrameManager.flushProfileAchievement();
    }
}
